/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.exception;

/**
 * @author haolw
 * @time 2017/06/27
 */
public enum ErrorType {
    SYSTEM_ERROR(800, "系统错误", "system error"),
    SERVER_FAILURE(801, "服务器处理失败", "server failure"),
    MAIL_FAILURE(802, "邮件发送失败", "mail failure"),
    NOT_EXIST_RECORD(803, "不存在的数据", "the data does not exist"),
    NO_AUTH(804, "无权限", "no auth"),
    NO_SERVICE(806, "无服务", "no service"),
    INVALID_TOKEN(808, "无效的token", "invalid token"),
    NO_OPEN_SERVICE(809, "未开通该服务", "no open service"),
    USER_NOT_LOGIN(90000, "无效的登录！", "user not login"),
    USER_LOGIN_ERROR(90001, "用户名或密码错误！", "userName or password is wrong"),
    VERIFY_CODE_ERROR(90002, "验证码错误", "verify code error"),
    NO_USER(90003, "该用户不存在", "user does not exist"),
    REGISTERED_PHONE(90004, "手机号已被注册", "phone number has been registered"),
    REGISTERED_EMAIL(90005, "邮箱已被注册", "email has been registered"),
    OLD_PASSWORD_ERROR(90006, "原密码错误", "original password error"),
    NO_EMAIL_USER(90007, "查找不到该邮箱", "cannot find this email"),
    PHONE_EMAIL_REGISTERED(90008, "手机号或邮箱已被注册", "phone or email has been registered"),
    INVALID_ACCOUNT(90010, "账号无效", "account invalid"),
    INVALID_COMPANY(90011, "不存在该公司", "company invalid"),
    INVALID_PAY_CODE(90012, "不存在该聚合码", "pay code invalid"),
    USED_PAY_CODE(90013, "该聚合码已被使用", "pay code had used"),

    INCOMPLETE_PARAMETERS(90020, "参数不完整", "incomplete parameters"),
    UNLAWFUL_PARAMETERS(90021, "不合法的参数", "unlawful parameters"),
    INVALID_FEE(90022, "无效的金额", "invalid fee"),
    REPEATED_DATA(90023, "重复的数据", "repeated data"),
    SIGNATURE_ERROR(90024, "签名错误", "signature error"),
    PLACE_ORDER_FAILURE(90030, "下单失败", "place order failure"),
    INVALID_BINDING(90051, "无效的绑定", "Invalid binding"),
    DUPLICATION_BINDING(90052, "重复的绑定", "Duplication binding"),
    ORDER_NOT_EXIST(90100, "订单不存在", "Order not exist!"),
    ORDER_ERROR(90101, "订单异常", "Order error!"),
    DRAWBACK_FAIL(90102, "申请退款失败", "Drawback failed!"),

    ;

    private Integer code;
    private String zhCnMsg;
    private String enMsg;

    ErrorType(Integer code, String zhCnMsg, String enMsg) {
        this.code = code;
        this.zhCnMsg = zhCnMsg;
        this.enMsg = enMsg;
    }

    public static ErrorType get(Integer code) {
        for (ErrorType errorType : ErrorType.values()) {
            if (errorType.getCode().equals(code)) {
                return errorType;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getZhCnMsg() {
        return zhCnMsg;
    }

    public void setZhCnMsg(String zhCnMsg) {
        this.zhCnMsg = zhCnMsg;
    }

    public String getEnMsg() {
        return enMsg;
    }

    public void setEnMsg(String enMsg) {
        this.enMsg = enMsg;
    }
}
